/**
 * The contents of this file are subject to the license and copyright detailed in the LICENSE and NOTICE files at the root of the source tree and available online at
 * http://www.askosi.org/license.html
 */
package be.destin.skos.html;

import java.util.TreeSet;

import be.destin.beans.Reflector;

/*
 * Record an error attached to an object and provide services around it
 */
public class LocalError extends TreeSet<String>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String toHtml(SkosHtmlManager skosHtmlManager, Object subject, Object parent) {
		if (this.size()==0) return "";
		Object[] beans = new Object[parent == null ? 1 : 2];
		beans[0] = subject ;
		if (parent != null) beans[1] = parent;
		StringBuffer result = new StringBuffer();
		result.append("<ul class=\"LocalError\">");
		for (String message : this) {
			result.append("<li>");
			result.append(Reflector.substituteURL(skosHtmlManager.getApplicationRoot(),beans,message,skosHtmlManager.getLanguage()));
			result.append("</li>");
		}
		result.append("</ul>");
		return result.toString();
	}
}
